package com.qianfeng.controller;

import com.qianfeng.dto.Page;
import com.qianfeng.entity.ChargeProject;
import com.qianfeng.service.ChargeProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
public class ChargeProjectController {
    @Autowired
    private ChargeProjectService chargeProjectService;

    @RequestMapping("/getChargeProjectList")
    public String getChargeProjectList(){
        return "08_charge_item_management";
    }

    @ResponseBody
    @RequestMapping("/getChargeProjectPage")
    public Page getChargeProjectPage(Integer pageNo,Integer pageSize) {
        int pageNo_ = 1;
        int pageSize_ = 2;
        if (pageNo != null) {
            pageNo_ = pageNo;
        }
        if (pageSize != null) {
            pageSize_ = pageSize;
        }
        Page page = chargeProjectService.getChargeProjectPage(pageNo_, pageSize_);
        return page;
    }
    @RequestMapping("/jumpAddChargeProject")
    public String jumpAddChargeProject(){
        return "08_01_charge_item_management_add";
    }
    @RequestMapping("/addChargeProject")
    public String addChargeProject(ChargeProject chargeProject){
        chargeProjectService.addChargeProject(chargeProject);
        return "08_charge_item_management";
    }
    @RequestMapping("/jumpUpdateChargeProject")
    public String jumpUpdateChargeProject(Integer cpId, Map map){
        ChargeProject chargeProject = chargeProjectService.getChargeProjectById(cpId);
        map.put("chargeProject",chargeProject);
        return "08_02_charge_item_management_update";
    }
    @RequestMapping("/updateChargeProject")
    public String updateChargeProject(ChargeProject chargeProject){
        chargeProjectService.updateChargeProject(chargeProject);
        return "08_charge_item_management";
    }
    @RequestMapping("/deleteChargeProject")
    public String deleteChargeProject(Integer cpId){
        chargeProjectService.deleteChargeProject(cpId);
        return "08_charge_item_management";
    }
    @RequestMapping("/getChargeProjectDtail")
    public String getChargeProjectDtail(Integer cpId,Map map){
        ChargeProject chargeProject = chargeProjectService.getChargeProjectById(cpId);
        map.put("chargeProject",chargeProject);
        return "08_03_charge_item_management_detail";
    }









}
